home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 11 / Mac Magazin and MacEasy Magazine CD - Issue 11.iso / Sharewarebibliothek / Entwickler / CDEF-DeBugger 2.0 ƒ / Window-Main.c < prev   
Text File  |  1995-05-31  |  3KB  |  82 lines

  1. // include files
  2. //#include "MyProject.h"
  3.  
  4. // prototypes
  5. void     DrawMyWindow( void );
  6. void    UpdateMainWindow( WindowPtr theWindow );
  7.  
  8. // globals
  9. Main            myMain;
  10.  
  11. /******************************************************************
  12.  
  13.     Create the main window and any additional items that need
  14.     initialization.
  15.     
  16. ******************************************************************/
  17. void     DrawMyWindow( void )
  18. {
  19.     Rect        theRect;
  20.     short        cntlID, variation;
  21.     CntlParam    myParam;
  22.     
  23.     // create our window and give it a real catchy name.
  24.     SetRect( &theRect, 20, 60, 300, 200 );
  25.     myMain.window = NewCWindow( nil, &theRect, "\pCDEF - DeBugger v1.0", 1, 0, (WindowPtr)-1, 1, MAIN_WINDOW );
  26.     SetPort( myMain.window );
  27.     
  28.     // create our control and store it in our window struct
  29.     cntlID         = 128;
  30.     variation     = 0;
  31.     SetRect( &theRect, (*myMain.window).portRect.left + 20, (*myMain.window).portRect.top + 60,
  32.                        (*myMain.window).portRect.right - 20, (*myMain.window).portRect.top + 76 );
  33.     
  34.     // set up the parameters for our control
  35.     myParam.theWindow      = myMain.window;
  36.     myParam.cntlRect       = theRect;
  37.     myParam.title[0]       = 0x00;
  38.     myParam.visible       = true;
  39.     myParam.initialValue = 0;
  40.     myParam.min             = -360;
  41.     myParam.max          = 360;
  42.     myParam.cntlType     = ( cntlID * 16 ) + variation;
  43.     
  44.     // now let's set up our funky control
  45.     SetUpMyControl( myParam );
  46.     
  47.     // for kicks I also provided apples standard scroll bar.
  48.     SetRect( &theRect, (*myMain.window).portRect.left + 20, (*myMain.window).portRect.top + 100,
  49.                        (*myMain.window).portRect.right - 20, (*myMain.window).portRect.top + 116 );
  50.     myMain.hAppleControl = NewControl( myMain.window, &theRect, "\p", 1, 0, -360, 360, 16, 0L );
  51.     
  52.     UpdateMainWindow( myMain.window );
  53. }
  54.  
  55. /******************************************************************
  56.  
  57.     Draw the main window.
  58.     
  59. ******************************************************************/
  60. void    UpdateMainWindow( WindowPtr theWindow )
  61. {
  62.     Rect        winRect = (*theWindow).portRect;
  63.     short         strWidth, winCenter;
  64.     Str255        theString = "\pYou should see a swell CDEF at this point.";
  65.     
  66.     // first erase the window?
  67.     EraseRect( &winRect );
  68.     
  69.     // draw your control
  70.     DrawControls( myMain.window );
  71.     
  72.     // Add a message to remind yourself.. "Hey I should see my CDEF at this point"
  73.     // in case your just staring at a blank window.
  74.     TextFont( 9 );
  75.     TextSize( 9 );
  76.     strWidth = StringWidth( theString );
  77.     winCenter = ( winRect.right - winRect.left ) / 2;
  78.     MoveTo( winCenter - ( strWidth / 2 ), 20 );
  79.     DrawString( theString );
  80.     TextFont( 0 );
  81.     TextSize( 12 );
  82. }